﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;
using System.Net.Mail;
using System.Web.Services;
using AjaxControlToolkit;
using System.IO.MemoryMappedFiles;

public partial class admin_client_buy_update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["email"] == null)
        {
            Response.Redirect("sessiont.aspx");
        }
        int s = 0;
        Label7.Text = s.ToString();
        Label2.Text = Session["email"].ToString();

       

        if (Page.IsPostBack)
        {
        }
        else
        {

            SqlConnection conn = null;
            conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
            conn.Open();
            SqlCommand scmd = new SqlCommand("SELECT * FROM  client_add_buy where c_id='" + Session["c_id"] + "'", conn);

            SqlDataReader dr = scmd.ExecuteReader();
            if (dr.Read())
            {


                
                txtmname.Text = dr[6].ToString();
                txtname1.Text = dr[7].ToString();
                txthno.Text = dr[8].ToString();
                txtcity.Text = dr[9].ToString();
                txtstreet.Text = dr[10].ToString();
                txtssn.Text = dr[11].ToString();
                txtzip.Text = dr[12].ToString();
                txtcountry.Text = dr[13].ToString();
                txtemail.Text = dr[14].ToString();
                txtphno.Text = dr[15].ToString();
                TextBox3.Text = dr[16].ToString();

                TextBox4.Text = dr[17].ToString();
                TextBox5.Text = dr[18].ToString();

              
                TextBox7.Text = dr[20].ToString();
                TextBox8.Text = dr[21].ToString();
                TextBox9.Text = dr[22].ToString();
               


                TextBox12.Text = dr[24].ToString();
               



                TextBox10.Text = dr[27].ToString();
                TextBox15.Text = dr[28].ToString();
                TextBox16.Text = dr[29].ToString();
               


                TextBox18.Text = dr[31].ToString();
                TextBox13.Text = dr[32].ToString();
                
           
              
                //string str = "0";
                //if (str.Equals(0))
                //{
                //    CheckBox9.Checked= t

                //}

                Label8.Text = Session["c_id"].ToString();





            }


            dr.Close();
        }
    }
        protected void Save_Click(object sender, EventArgs e)

    {
        


        string p_size = TextBox11.Text + DropDownList7.SelectedValue;
        string balcony = DropDownList14.SelectedValue + TextBox6.Text;
        SqlConnection conn = null;
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn.Open();

        SqlCommand cm1 = new SqlCommand("update  client_add_buy set type='"+ DropDownList8.SelectedValue+"', property= '"+DropDownList9.SelectedValue+"',c_type='" +DropDownList20.SelectedValue+"',agent_name='"+ DropDownList15.SelectedValue+"',client_fullname='"+txtmname.Text+"' ,property_type='" +txtname1.Text+"',house_no='"+ txthno.Text+"',city='"+ txtcity.Text+"',street='"+ txtstreet.Text+"',ssn='"+ txtssn.Text+"', zip='"+ txtzip.Text+"' ,country='"+ txtcountry.Text+"',email_id='"+ txtemail.Text+"',phone='"+ txtphno.Text+"',room_no='"+ TextBox3.Text+"',floor='"+TextBox4.Text+"',store='"+ TextBox5.Text+"',ac='"+DropDownList16.Text+"',parking='"+TextBox7.Text+"',elevator='"+ TextBox8.Text+"',price='"+ TextBox9.Text+"', prop_size='"+ p_size+"',entering_date='" +TextBox12.Text+"',condtion='" +DropDownList13.SelectedValue+"',  balconies='"+ balcony+"', a_hours='"+ TextBox10.Text+"', safe_room='"+ TextBox15.Text+"'  , budget='"+ TextBox16.Text+"',purpose='"+ DropDownList17.SelectedValue+"',nghrhood='"+ TextBox18.Text+"' ,comment='"+ TextBox13.Text+"',financing='"+ DropDownList18.SelectedValue+"',custom_name='"+ DropDownList19.SelectedValue+"',category='"+ ddlcategory.SelectedValue+"',c_cat='"+ DropDownList1.SelectedValue+"' where c_id='" + Session["c_id"] + "'", conn);
        cm1.ExecuteNonQuery();
        Response.Redirect("partner_update_client_conf.aspx");
        conn.Close();
    }
    protected void Cancel_Click(object sender, EventArgs e)
    {

    }
    protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
    {
       
    }
    protected void LinkButton1_Click(object sender, System.EventArgs e)
    {
        Session.Abandon();
          Response.Redirect("../partner.aspx");
    }
}
